package com.xcity.game.buff;

import com.xcity.game.buff.effect.AutoCompleteDailyTaskEffect;
import com.xcity.game.buff.effect.FinishBuildAtOnceEffect;
import com.xcity.game.buff.effect.ProtectAssetsEffect;
import com.xcity.game.buff.effect.ReduceBuildCDEffect;
import com.xcity.game.buff.effect.WatchdogEffect;
import com.xcity.game.buff.effect.WorldEventBuffEffect;

import gnu.trove.map.TIntObjectMap;
import gnu.trove.map.hash.TIntObjectHashMap;

public class BuffEffectFactory {
	
	static enum Effect {
		AUTO_COMPLETE_DAILY_TASK(BuffEffector.BUFF_AUTO_COMPLETE_DAILY_TASK, new AutoCompleteDailyTaskEffect()),
		FINISH_BUILD_AT_ONCE(BuffEffector.BUFF_FINISH_BUILD_AT_ONCE, new FinishBuildAtOnceEffect()),
		PROTECT_ASSETS(BuffEffector.BUFF_PROTECT_ASSETS, new ProtectAssetsEffect()),
		REDUCE_BUILD_CD(BuffEffector.BUFF_REDUCE_BUILD_CD, new ReduceBuildCDEffect()),
		WORLD_EVENT_BUFF(BuffEffector.BUFF_WORLD_EVENT, new WorldEventBuffEffect()),
		WATCHDOG(BuffEffector.BUFF_WATCH_DOG, new WatchdogEffect()),
		;
		final int effectId;
		final BuffEffector effector;
		Effect(int effectId, BuffEffector effector) {
			this.effectId = effectId;
			this.effector = effector;
		}
	}
	
	static TIntObjectMap<BuffEffector> effectors = new TIntObjectHashMap<BuffEffector>();
	static {
		Effect[] vals = Effect.values();
		for (Effect val : vals) {
			effectors.put(val.effectId, val.effector);
		}
	}

	public static BuffEffector create(Buff buff) {
		return effectors.get(buff.getTemplate().getEffectId());
	}
	
}
